
#include <signal.h>
#include <unistd.h>

static bool g_bStop = false;
void inner_signal_handler(int signum)
{
    g_bStop = true;
}

static void inner_register_sigaction()
{
    struct sigaction act = {0};

    act.sa_handler = inner_signal_handler;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, SIGSTOP);
    sigaddset(&act.sa_mask, SIGTERM);
    sigaction(SIGINT, &act, NULL);

    act.sa_handler = inner_signal_handler;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, SIGSTOP);
    sigaddset(&act.sa_mask, SIGINT);
    sigaction(SIGTERM, &act, NULL);
}

int main(int argc, char **argv)
{
    inner_register_sigaction();
    while (!g_bStop)
    {
        sleep(1000);
    }
    return 0;
}